{"ast":null,"code":"import _slicedToArray from\"/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/@babel/runtime/helpers/esm/slicedToArray.js\";import React from'react';import classNames from\"classnames\";import{MessageDate,MessageStatus,AudioMessage,Avatar,Name}from\"../index\";import{getUserName}from\"../../utils/User\";import{Context}from\"../../index\";import{isMe,checkMimeType}from\"../../utils/Message\";import'./Message.scss';import{jsx as _jsx}from\"react/jsx-runtime\";import{jsxs as _jsxs}from\"react/jsx-runtime\";var Message=function Message(_ref){var _message$bodyMessage,_message$bodyMessage2;var message=_ref.message,_ref$replyStatus=_ref.replyStatus,replyStatus=_ref$replyStatus===void 0?false:_ref$replyStatus;var _React$useState=React.useState(false),_React$useState2=_slicedToArray(_React$useState,2),isMyMessage=_React$useState2[0],setIsMyMessage=_React$useState2[1];var _React$useContext=React.useContext(Context),store=_React$useContext.store;React.useEffect(function(){setIsMyMessage(isMe(message.user,store));},[message,store]);return/*#__PURE__*/_jsx(\"div\",{className:classNames('message',{'message--isme':isMyMessage&&!replyStatus,'message--reply':replyStatus}),children:/*#__PURE__*/_jsxs(\"div\",{className:classNames('message__content',{'message__content--borderLine':replyStatus}),children:[/*#__PURE__*/_jsx(MessageStatus,{replyStatus:replyStatus,message:message,store:store}),!replyStatus&&/*#__PURE__*/_jsx(\"div\",{className:\"message__avatar\",children:/*#__PURE__*/_jsx(Avatar,{contentList:message.user.content,alt:getUserName(message.user),stringForFirstCharacter:getUserName(message.user),stringForGenerateColor:message.user.id})}),/*#__PURE__*/_jsxs(\"div\",{className:\"message__info\",children:[replyStatus&&/*#__PURE__*/_jsx(\"div\",{className:\"message__reply\",children:/*#__PURE__*/_jsx(\"span\",{children:\"\\u041F\\u0435\\u0440\\u0435\\u0441\\u043B\\u0430\\u043D\\u043D\\u043E\\u0435 \\u0441\\u043E\\u043E\\u0431\\u0449\\u0435\\u043D\\u0438\\u0435\"})}),/*#__PURE__*/_jsx(Name,{user:message.user}),(message.bodyMessage&&message.bodyMessage.message&&message.bodyMessage.message.length!==0||message.reply&&message.reply.items&&message.reply.items.length!==0)&&/*#__PURE__*/_jsxs(\"div\",{className:\"message__bubble\",children:[message.bodyMessage&&((_message$bodyMessage=message.bodyMessage)===null||_message$bodyMessage===void 0?void 0:_message$bodyMessage.message)&&/*#__PURE__*/_jsx(\"p\",{className:\"message__text\",children:(_message$bodyMessage2=message.bodyMessage)===null||_message$bodyMessage2===void 0?void 0:_message$bodyMessage2.message}),message.reply&&message.reply.items&&message.reply.items.length>0&&message.reply.items.map(function(item){return/*#__PURE__*/_jsx(Message,{message:item,replyStatus:true},item.id);})]}),message.bodyMessage&&message.bodyMessage.content&&message.bodyMessage.content.items&&message.bodyMessage.content.items.length>0&&/*#__PURE__*/_jsx(\"div\",{className:\"message__attachments\",children:message.bodyMessage.content.items.length!==1&&message.bodyMessage.content.items.map(function(item){return checkMimeType(item,'audio')&&/*#__PURE__*/_jsx(AudioMessage,{content:item,isMe:isMyMessage,replyStatus:replyStatus},item.id)||checkMimeType(item,'image')&&/*#__PURE__*/_jsx(\"div\",{className:\"message__attachments-item\",children:/*#__PURE__*/_jsx(\"img\",{src:item.link,alt:item.id?item.id:'attachments '+item.link})},item.id);})||message.bodyMessage.content.items.length===1&&message.bodyMessage.content.items.map(function(item){return checkMimeType(item,'audio')&&/*#__PURE__*/_jsx(AudioMessage,{content:item,isMe:isMyMessage,replyStatus:replyStatus},item.id)||checkMimeType(item,'image')&&/*#__PURE__*/_jsx(\"div\",{className:\"message__attachments-item--onlyOneItem\",children:/*#__PURE__*/_jsx(\"img\",{src:item.link,alt:item.id?item.id:'attachments '+item.link})},item.id);})}),/*#__PURE__*/_jsx(MessageDate,{message:message})]})]})});};export default Message;","map":{"version":3,"names":["React","classNames","MessageDate","MessageStatus","AudioMessage","Avatar","Name","getUserName","Context","isMe","checkMimeType","Message","message","replyStatus","useState","isMyMessage","setIsMyMessage","useContext","store","useEffect","user","content","id","bodyMessage","length","reply","items","map","item","link"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/src/components/Message/index.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from \"classnames\";\nimport {MessageProps} from \"../../models/props/MessageProps\";\nimport {MessageDate, MessageStatus, AudioMessage, Avatar, Name} from \"../index\";\nimport {getUserName} from \"../../utils/User\";\nimport {Context} from \"../../index\";\nimport {isMe, checkMimeType} from \"../../utils/Message\";\nimport './Message.scss';\n\nconst Message: React.FC<MessageProps> = ({message, replyStatus = false}) => {\n    const [isMyMessage, setIsMyMessage] = React.useState<boolean>(false);\n    const {store} = React.useContext(Context);\n\n    React.useEffect(() => {\n        setIsMyMessage(isMe(message.user, store));\n    }, [message, store]);\n\n    return (\n        <div className={classNames('message',\n            {\n                'message--isme': isMyMessage && !replyStatus,\n                'message--reply': replyStatus\n            })}>\n            <div className={classNames('message__content',\n                {'message__content--borderLine': replyStatus})}>\n                <MessageStatus replyStatus={replyStatus} message={message} store={store} />\n                {!replyStatus && <div className='message__avatar'>\n                    <Avatar\n                        contentList={message.user.content}\n                        alt={getUserName(message.user)}\n                        stringForFirstCharacter={getUserName(message.user)}\n                        stringForGenerateColor={message.user.id}\n                    />\n                </div>}\n                <div className='message__info'>\n                    {replyStatus &&\n                        <div className='message__reply'>\n                            <span>Пересланное сообщение</span>\n                        </div>\n                    }\n                    <Name user={message.user} />\n                    {\n                        ((message.bodyMessage &&\n                            message.bodyMessage.message &&\n                            message.bodyMessage.message.length !== 0) ||\n                            (message.reply && message.reply.items && message.reply.items.length !== 0)) &&\n                        <div className='message__bubble'>\n                            {message.bodyMessage && message.bodyMessage?.message &&\n                                <p className='message__text'>{message.bodyMessage?.message}</p>\n                            }\n                            {\n                                message.reply && message.reply.items && message.reply.items.length > 0 &&\n                                message.reply.items.map((item)=>\n                                    <Message key={item.id} message={item} replyStatus={true} />\n                                )\n                            }\n                        </div>\n                    }\n                        {\n                            (message.bodyMessage && message.bodyMessage.content &&\n                                message.bodyMessage.content.items && message.bodyMessage.content.items.length > 0) && (\n                                    <div className='message__attachments'>\n                                        {\n                                            (message.bodyMessage.content.items.length !== 1 &&\n                                            message.bodyMessage.content.items.map((item) =>\n                                                (checkMimeType(item, 'audio') &&\n                                                    <AudioMessage content={item} isMe={isMyMessage} replyStatus={replyStatus} key={item.id}/>) ||\n                                                (checkMimeType(item, 'image') &&\n                                                    <div className='message__attachments-item' key={item.id}>\n                                                        <img src={item.link} alt={item.id ? item.id : 'attachments ' + item.link}/>\n                                                    </div>)\n                                            )) || (\n                                            message.bodyMessage.content.items.length === 1 &&\n                                            message.bodyMessage.content.items.map((item) =>\n                                                (checkMimeType(item, 'audio') &&\n                                                    <AudioMessage content={item} isMe={isMyMessage} replyStatus={replyStatus} key={item.id}/>) ||\n                                                (checkMimeType(item, 'image') &&\n                                                    <div className='message__attachments-item--onlyOneItem' key={item.id}>\n                                                        <img src={item.link} alt={item.id ? item.id : 'attachments ' + item.link}/>\n                                                    </div>)\n                                            ))\n                                        }\n                                    </div>\n                            )\n                        }\n                    <MessageDate message={message} />\n                </div>\n            </div>\n        </div>\n    );\n}\n\nexport default Message;"],"mappings":"8IAAA,MAAOA,MAAK,KAAM,OAAO,CACzB,MAAOC,WAAU,KAAM,YAAY,CAEnC,OAAQC,WAAW,CAAEC,aAAa,CAAEC,YAAY,CAAEC,MAAM,CAAEC,IAAI,KAAO,UAAU,CAC/E,OAAQC,WAAW,KAAO,kBAAkB,CAC5C,OAAQC,OAAO,KAAO,aAAa,CACnC,OAAQC,IAAI,CAAEC,aAAa,KAAO,qBAAqB,CACvD,MAAO,gBAAgB,CAAC,wFAExB,GAAMC,QAA+B,CAAG,QAAlCA,QAA+B,MAAuC,mDAAlCC,QAAO,MAAPA,OAAO,uBAAEC,WAAW,CAAXA,WAAW,2BAAG,KAAK,kBAClE,oBAAsCb,KAAK,CAACc,QAAQ,CAAU,KAAK,CAAC,oDAA7DC,WAAW,qBAAEC,cAAc,qBAClC,sBAAgBhB,KAAK,CAACiB,UAAU,CAACT,OAAO,CAAC,CAAlCU,KAAK,mBAALA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